package com.ruoyi.mywork.controller;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ruoyi.common.core.redis.ICache;
import com.ruoyi.mywork.repository.dao.MyTestDao;
import com.ruoyi.mywork.repository.generator.entity.PCache;
import com.ruoyi.mywork.repository.generator.entity.PCacheExample;
import com.ruoyi.mywork.repository.generator.entity.SysUserGen;
import com.ruoyi.mywork.repository.generator.mapper.SysUserGenMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/test")
public class MyTestController {

    @Autowired
    private SysUserGenMapper sysUserGenMapper;
    @Autowired
    private MyTestDao myTestDao;
    @Autowired
    private ICache cache;

    @GetMapping("/test1")
    public Object test1() {
        PageHelper.startPage(1, 2);
        Page<SysUserGen> page = (Page<SysUserGen>) sysUserGenMapper.selectByExample(null);

        PageInfo pi = new PageInfo(page);

        cache.setCacheObject("tmp", "asdfasdf");
        String pi2 = cache.getCacheObject("tmp");

        return page;

    }
    @GetMapping("/test2")
    public Object test2() {
        return myTestDao.select1();

    }
    @GetMapping("/test3")
    public Object test3() {
        PageHelper.startPage(1, 2);
        List<SysUserGen> page = myTestDao.select2();

        return page;
    }

    @Value("${location.flag}")
    private String locationFlag;

    @GetMapping("/test4")
    public Object test4() {
        return locationFlag;
    }
}
